import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '@/layout'
// 超级管理员菜单
export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    // 用户管理路由
    path: '/',
    component: Layout,
    redirect: '/user', //重定向为后台用户页
    children: [{
      path: 'user',
      name: 'user',
      component: () => import('@/views/usercontrol'),
      meta: { title: '用户管理', icon: 'user' }
    }]
  },
  {
    // 示范平台申报审核路由
    path: '/example',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'example',
        component: () => import('@/views/nested'),
        meta: { title: '示范平台申报审核', icon: 'example', }
      }
    ]
  },
  {
    // 示范基地申报审核路由
    path: '/larry',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'larry',
        component: () => import('@/views/dashboard'),
        meta: { title: '示范基地申报审核', icon: 'nested', }
      }
    ]
  },
  {
    // 入驻机构申报审核
    path: '/settle',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Settle',
        component: () => import('@/views/hosting'),
        meta: { title: '入驻机构申报审核', icon: 'tree' }
      }
    ]
  },
  {
    // 示范平台申报年审
    path: '/exampleyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'exampleyear',
        component: () => import('@/views/exampleyear'),
        meta: { title: '示范平台申报年审', icon: 'example' }
      }
    ]
  },
  {
    // 示范基地申报审核
    path: '/larryyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'larryyear',
        component: () => import('@/views/larryyear'),
        meta: { title: '示范基地申报年审',  icon: 'nested', }
      }
    ]
  },
  {
    // 入驻机构申报年审
    path: '/settleyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'settleyear',
        component: () => import('@/views/settleyear'),
        meta: { title: '入驻机构申报年审', icon: 'tree' }
      }
    ]
  },
  {
    // 融资需求管理路由
    path: '/financing',
    component: Layout,
    name: 'financing',
    children: [
      {
        path: 'index',
        name: 'financing',
        component: () => import('@/views/form'),
        meta: { title: '融资需求管理', icon: 'dashboard' }
      }
    ]
  },
  {
    // 企业留言管理
    path: '/nested',
    component: Layout,
    name: 'Nested',
    children: [
      {
        path: 'index',
        name: 'nested',
        component: () => import('@/views/demonstration'),
        meta: { title: '企业留言管理', icon: 'table' }
      }
    ]
  },
  {
    // 公告公示路由
    path: '/announcement',
    component: Layout,
    name: 'announcement',
    children: [
      {
        path: 'index',
        name: 'announcement',
        component: () => import('@/views/announcement'),
        meta: { title: '公告公示', icon: 'eye' }
      }
    ]
  },
  {
    // 管理员中心
    path: '/admin',
    component: Layout,
    name: 'admin',
    children: [
      {
        path: 'index',
        name: 'admin',
        component: () => import('@/views/admin'),
        meta: { title: '管理员中心', icon: 'user' }
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]
// 双创管理员菜单
export const twoconstantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    // 用户管理路由
    path: '/',
    component: Layout,
    redirect: '/user', //重定向为后台用户页
    children: [{
      path: 'user',
      name: 'user',
      component: () => import('@/views/usercontrol'),
      meta: { title: '用户管理', icon: 'user' }
    }]
  },
  {
    // 示范平台申报审核路由
    path: '/example',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'example',
        component: () => import('@/views/nested'),
        meta: { title: '示范平台申报审核', icon: 'example', }
      }
    ]
  },
  {
    // 示范基地申报审核路由
    path: '/larry',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'larry',
        component: () => import('@/views/dashboard'),
        meta: { title: '示范基地申报审核', icon: 'nested', }
      }
    ]
  },
  {
    // 示范平台申报年审
    path: '/exampleyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'exampleyear',
        component: () => import('@/views/exampleyear'),
        meta: { title: '示范平台申报年审', icon: 'example' }
      }
    ]
  },
  {
    // 示范基地申报审核年审
    path: '/larryyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'larryyear',
        component: () => import('@/views/larryyear'),
        meta: { title: '示范基地申报年审',  icon: 'nested', }
      }
    ]
  },
  {
    // 融资需求管理路由
    path: '/financing',
    component: Layout,
    name: 'financing',
    children: [
      {
        path: 'index',
        name: 'financing',
        component: () => import('@/views/form'),
        meta: { title: '融资需求管理', icon: 'dashboard' }
      }
    ]
  },
  {
    // 企业留言管理
    path: '/nested',
    component: Layout,
    name: 'Nested',
    children: [
      {
        path: 'index',
        name: 'nested',
        component: () => import('@/views/demonstration'),
        meta: { title: '企业留言管理', icon: 'table' }
      }
    ]
  },
  {
    // 公告公示路由
    path: '/announcement',
    component: Layout,
    name: 'announcement',
    children: [
      {
        path: 'index',
        name: 'announcement',
        component: () => import('@/views/announcement'),
        meta: { title: '公告公示', icon: 'eye' }
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]
//入驻机构仅信息科审核员菜单
export const threeconstantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    // 用户管理路由
    path: '/',
    component: Layout,
    redirect: '/user', //重定向为后台用户页
    children: [{
      path: 'user',
      name: 'user',
      component: () => import('@/views/usercontrol'),
      meta: { title: '用户管理', icon: 'user' }
    }]
  },
  {
    // 入驻机构申报审核
    path: '/settle',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Settle',
        component: () => import('@/views/hosting'),
        meta: { title: '入驻机构申报审核', icon: 'tree' }
      }
    ]
  },
  {
    // 入驻机构申报年审
    path: '/settleyear',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'settleyear',
        component: () => import('@/views/settleyear'),
        meta: { title: '入驻机构申报年审', icon: 'tree' }
      }
    ]
  },
  {
    // 融资需求管理路由
    path: '/financing',
    component: Layout,
    name: 'financing',
    children: [
      {
        path: 'index',
        name: 'financing',
        component: () => import('@/views/form'),
        meta: { title: '融资需求管理', icon: 'dashboard' }
      }
    ]
  },
  {
    // 企业留言管理
    path: '/nested',
    component: Layout,
    name: 'Nested',
    children: [
      {
        path: 'index',
        name: 'nested',
        component: () => import('@/views/demonstration'),
        meta: { title: '企业留言管理', icon: 'table' }
      }
    ]
  },
  {
    // 公告公示路由
    path: '/announcement',
    component: Layout,
    name: 'announcement',
    children: [
      {
        path: 'index',
        name: 'announcement',
        component: () => import('@/views/announcement'),
        meta: { title: '公告公示', icon: 'eye' }
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  mode: 'hash',
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
